package ai.mspbots.service.users.controller;

import ai.mspbots.service.users.feign.ReportFeignClient;
import ai.mspbots.service.users.feign.TaskFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/feign")
public class FeignController {

    @Autowired
    private TaskFeignClient taskFeignClient;
    @Autowired
    private ReportFeignClient reportFeignClient;

    @GetMapping("/task/{id}")
    public Map<String, Object> getTask(@PathVariable("id") Long id) {
        Map<String, Object> task = taskFeignClient.getTask(id);
        Map<String, Object> report = reportFeignClient.getReport(id);
        Map<String, Object> result = new HashMap<>();
        result.put("task", task);
        result.put("report", report);
        return result;
    }
}
